<!-- Phan khai bao bien cuc bo-->
<?php
$v_page=1;
if(isset($_REQUEST['hdn_page'])){
	$v_page=intval($_REQUEST['hdn_page']);
}

$v_recordtype_filter = $_SESSION['onegate_current_recordtype'];
$v_count = sizeof($arr_all_record);
$v_current_style_name = "odd_row";
// xac dinh label hien thi: trinh ky, duoc giai quyet, khong duoc giai quyet
$arr_result_label = onegate_get_label_of_result_type($_SESSION['recordtype'],$v_recordtype_filter);

if (isset($v_xml_file_name) && !is_null($v_xml_file_name)){
	$v_table_struct_xml_file = "../../xml/".$v_recordtype_filter."/".$v_xml_file_name;
}else{
	$v_table_struct_xml_file = "../../xml/".$v_recordtype_filter."/danh_sach_ho_so_luu.xml";		
}

if (file_exists($v_table_struct_xml_file)){
	$v_table_struct_xml_string = _read_file($v_table_struct_xml_file);
	
}else{
	if (isset($v_xml_file_name) && !is_null($v_xml_file_name)){
		$v_table_struct_xml_file = "../../xml/other/".$v_xml_file_name;
	}else{
		$v_table_struct_xml_file = "../../xml/other/danh_sach_ho_so_luu.xml";		
	}
	$v_table_struct_xml_string = _read_file($v_table_struct_xml_file);
}
$table_struct_rax = new RAX(); 
$table_struct_rec = new RAX(); 
$table_struct_rax->open($v_table_struct_xml_string);
$table_struct_rax->record_delim = 'table_struct_of_filter_form';
$table_struct_rax->parse();
$table_struct_rec = $table_struct_rax->readRecord(); 
$table_struct_row = $table_struct_rec->getRow();
$v_form_title = $table_struct_row["form_title"];
$v_first_col_width = $table_struct_row["first_col_width"];
$v_filter_xml_tag = $table_struct_row["filter_xml_tag"];
$v_second_col_width = (100-$v_first_col_width)."%";
///Begin//Form
$v_html_string = '';
//Begin//Bang chua cac thanh phan cua form
$v_html_string = $v_html_string . "<table width='100%'  border='0' cellspacing='0' cellpadding='0'><tr>";
$v_html_string = $v_html_string . "<td class='large_title'>".$v_form_title."</td>";
$v_html_string = $v_html_string . "</tr></table>";
//Bang chua cac bin hidden
$v_html_string = $v_html_string . "<table width='100%' cellpadding='0' cellspacing='0'><tr><td> ";
$v_html_string = $v_html_string . "<form action='index.php' method='post' name='f_dsp_single_conditions'> ";
$v_html_string = $v_html_string . "<input type='hidden' name='hdn_list_xml_tag' value=''>";
$v_html_string = $v_html_string . "<input type='hidden' name='hdn_list_xml_value' value=''>";
$v_html_string = $v_html_string . "<input type='hidden' name='fuseaction' value='DISPLAY_ALL_RECORD_ARCHIVES'>";
$v_html_string = $v_html_string . "<input type='hidden' name='hdn_recordtype_filter' value='".$v_recordtype_filter ."'>";
$v_html_string = $v_html_string . "<input type='hidden' name='hdn_record_id' value=''>";
$v_html_string = $v_html_string . "<input type='hidden' name='filter_xml_tag' value='".$v_filter_xml_tag."'>";
$v_html_string = $v_html_string . "<input type='hidden' name='hdn_page' value='".$v_page."'>";
$v_html_string = $v_html_string . "<input type='hidden' name='hdn_recordtype_filter_list' value='".$v_recordtype_filter_list."'>";
$v_html_string = $v_html_string . "</table>";
///Begin///Bang chua cac dong co dinh cua ho so
$v_html_string = $v_html_string . "<table width='100%'  border='0' cellspacing='0' cellpadding='0'>";
$v_html_string = $v_html_string . "<col width='20%'><col width='80%'>";
$v_html_string = $v_html_string . "<tr><td class='normal_label' align='left'>".CONST_RECORDTYPE_LABEL."</td>";
$v_html_string = $v_html_string . "<td><select class='normal_selectbox' name='sel_reporttype' style='width:100%' onChange='onchange_submit(this,document.forms(0).hdn_recordtype_filter,&quot;DISPLAY_ALL_RECORD_ARCHIVES&quot;);'>";
$v_html_string = $v_html_string . _generate_select_option($arr_all_recordtype,'0','0','1', $v_recordtype_filter);
$v_html_string = $v_html_string . "</select></td></tr>";
$v_html_string = $v_html_string . "</table>";
//Doc cac dong cua form	
$table_struct_rax = new RAX(); 
$table_struct_rec = new RAX(); 
$table_struct_rax->open($v_table_struct_xml_string);
$table_struct_rax->record_delim = 'row';
$table_struct_rax->parse();
$table_struct_rec = $table_struct_rax->readRecord(); 
//echo htmlspecialchars($v_xml_str);
while ($table_struct_rec) { 
	$table_struct_row = $table_struct_rec->getRow();
	$v_have_line_before = $table_struct_row["have_line_before"];
	$v_col_number = $table_struct_row["col_number"];
	$v_tag_list = $table_struct_row["tag_list"];
	$v_row_id = $table_struct_row["row_id"];
	$arr_tag = explode(",", $v_tag_list);
	if ($v_have_line_before=="true"){
		$v_html_string = $v_html_string . "<table width='100%'  border='0' cellspacing='0' cellpadding='0'><tr>";
		$v_html_string = $v_html_string . "<td><hr width='100%' color='#66CCFF' size='1'></td>";
		$v_html_string = $v_html_string . "</tr></table>";
	}
	//Bang chua mot dong cua form
	$v_html_string = $v_html_string . "<table width='100%' border='0' cellspacing='0' cellpadding='0'>";
	$v_html_table = "";
	$v_html_tag = "";									
	for($i=0;$i < sizeof($arr_tag);$i++){
		$formfield_rax = new RAX(); 
		$formfield_rec = new RAX(); 
		$formfield_rax->open($v_table_struct_xml_string);
		$formfield_rax->record_delim = $arr_tag[$i];
		$formfield_rax->parse();
		$formfield_rec = $formfield_rax->readRecord(); 
		$formfield_row = $formfield_rec->getRow(); 
		$v_label = $formfield_row["label"];
		$v_type = $formfield_row["type"];
		$v_dataformat = $formfield_row["data_format"];
		$v_width = $formfield_row["width"];
		$v_row = $formfield_row["row"];
		$v_max = $formfield_row["max"];
		$v_min = $formfield_row["min"];
		$v_maxlength = $formfield_row["maxlength"];
		$v_note = $formfield_row["note"];
		$v_message = $formfield_row["message"];
		$v_optional = $formfield_row["optional"];
		$v_xml_tag_in_db = $formfield_row["xml_tag_in_db"];
		$v_js_function_list = $formfield_row["js_function_list"];
		$v_js_action_list = $formfield_row["js_action_list"];
		$v_readonly_in_edit_mode = $formfield_row["readonly_in_edit_mode"];
		$v_disabled_in_edit_mode = $formfield_row["disabled_in_edit_mode"];
		if ($v_xml_str!=""){
			$column_rax = new RAX(); 
			$column_rec = new RAX();
			$column_rax->open($v_xml_str);
			$column_rax->record_delim = 'data_list';
			$column_rax->parse();
			$column_rec = $column_rax->readRecord(); 
			$column_row = $column_rec->getRow();
			$v_value = _restore_XML_bad_char($column_row[$v_xml_tag_in_db]); 
		}
		if ($v_type=="selectbox"){
			$v_selectbox_option_sql = $formfield_row["selectbox_option_sql"];
			$v_selectbox_id_column = $formfield_row["selectbox_option_id_column"];
			$v_selectbox_name_column = $formfield_row["selectbox_option_name_column"];
		}
		if ($v_type=="checkboxmultiple"){
			$v_checkbox_multiple_sql = $formfield_row["checkbox_multiple_sql"];
			$v_checkbox_multiple_id_column = $formfield_row["checkbox_multiple_id_column"];
			$v_checkbox_multiple_name_column = $formfield_row["checkbox_multiple_name_column"];
		}
		$v_html_table = $v_html_table . "<col width='$v_first_col_width'>" . "<col width='$v_second_col_width'>";		
		$v_html_tag = $v_html_tag . Generate_HTML_Input();		
	}
	$v_html_string = $v_html_string .  $v_html_table . "<tr id = '$v_row_id' style='display:block'>" . "<td class='normal_label'>" . $v_html_tag."</td>";
	$v_html_string = $v_html_string . "</tr></table>";
	$table_struct_rec = $table_struct_rax->readRecord();
}
$v_html_string = $v_html_string . "<table width='100%'  border='0' cellspacing='0' cellpadding='0'>";
$v_html_string = $v_html_string . "<col width='50%'><col width='50%'>";
$v_html_string = $v_html_string . '<tr><td align="left">';
$v_html_string = $v_html_string . '<input type="button" name="btn_query_data" class="small_button" value="'.CONST_QUERY_DATA_BUTTON.'" style="width:20%" onClick="save_hidden_list_item_id(document.forms(0).hdn_list_item_id_checked,document.forms(0).chk_item_id);save_list_onclick(document.forms(0),document.forms(0).hdn_list_xml_tag,document.forms(0).hdn_list_xml_value);check_value_in_form(&quot;DISPLAY_ALL_RECORD_ARCHIVES&quot;);" onKeyDown="change_focus(document.forms(0),this);">&nbsp;&nbsp;';
$v_html_string = $v_html_string . '<input type="button" name="btn_reset_data" class="small_button" value="'.CONST_RESET_BUTTON.'" style="width:20%" onClick="btn_reset_onclick(document.forms(0).hdn_list_xml_tag,document.forms(0).hdn_list_xml_value,&quot;DISPLAY_ALL_RECORD_ARCHIVES&quot;);" onKeyDown="change_focus(document.forms(0),this);">';
$v_html_string = $v_html_string . '</td></tr>';
$v_html_string = $v_html_string . "</table>";
//Bang chua cac thanh phan cua form
$table_struct_rax = new RAX(); 
$table_struct_rec = new RAX(); 
$table_struct_rax->open($v_table_struct_xml_string);
$table_struct_rax->record_delim = 'col';
$table_struct_rax->parse();
$table_struct_rec = $table_struct_rax->readRecord(); 
$v_html_string = $v_html_string  . '<table class="list_table2" width="100%" cellpadding="0" cellspacing="0">';
$v_html_temp_width = '';
$v_html_temp_label = '';
$v_column = 0;
while ($table_struct_rec) { 
	$table_struct_row = $table_struct_rec->getRow();
	$v_label = $table_struct_row["label"];
	$v_width = $table_struct_row["width"];
	$v_html_temp_width = $v_html_temp_width  . '<col width="'.$v_width .'">';
	$v_html_temp_label = $v_html_temp_label . '<td align="center">'.$v_label.'</td>';
	$table_struct_rec = $table_struct_rax->readRecord();
	$v_column ++;
}
$v_html_string = $v_html_string  . $v_html_temp_width;
$v_html_string = $v_html_string  . '<tr class="header">';
$v_html_string = $v_html_string  . $v_html_temp_label;
$v_html_string = $v_html_string  . '</tr></table>';
$v_html_string = $v_html_string  . '<div style="overflow: auto; width: 100%; height:'.(_CONST_HEIGHT_OF_LIST-20).';padding-left:0px;margin:0px">';
$v_html_string = $v_html_string  . '<table class="list_table2" width="100%" cellpadding="0" cellspacing="0">';
$v_html_string = $v_html_string  . $v_html_temp_width;
$v_count_row = 0;
$v_inc = 0;
//exit;
if ($v_count >0){
	for($row_index = 0;$row_index< $v_count ;$row_index++){
		$v_url = "";
		$v_received_record_xml_data = $arr_all_record[$row_index]['C_RECEIVED_RECORD_XML_DATA'];
		$v_recordset = $arr_all_record[$row_index];
		//Kiem tra xem ban ghi nay co thoa man dieu kien loc hay khong
		//if (!is_data_valid($v_recordset,$v_table_struct_xml_string,$v_xml_str)){
			//continue;
		//}
		if ($v_current_style_name == "odd_row"){
			$v_current_style_name = "round_row";
		}else{
			$v_current_style_name = "odd_row";
		}
		//$v_inc ++;	
		$v_count_row ++;
		$v_html_string = $v_html_string  .'<tr class="'.$v_current_style_name.'" >'; 
		$table_struct_rax = new RAX(); 
		$table_struct_rec = new RAX(); 
		$table_struct_rax->open($v_table_struct_xml_string);
		$table_struct_rax->record_delim = 'col';
		$table_struct_rax->parse();		
		$table_struct_rec = $table_struct_rax->readRecord(); 
		while ($table_struct_rec) { 
			$table_struct_row = $table_struct_rec->getRow();
			$v_type = $table_struct_row["type"];
			$v_width = $table_struct_row["width"];
			$v_align = $table_struct_row["align"];
			$v_xml_data = $table_struct_row["xml_data"];
			$v_column_name = $table_struct_row["column_name"];
			$v_xml_tag_in_db = $table_struct_row["xml_tag_in_db"];
			$v_php_function = $table_struct_row["php_function"];
			$v_selectbox_option_sql = $table_struct_row["selectbox_option_sql"];
			$arr_xml_tag_in_db = explode(".",$v_xml_tag_in_db);
			if (sizeof($arr_xml_tag_in_db)>1){
				$v_received_record_xml_data = $arr_all_record[$row_index][$arr_xml_tag_in_db[0]];
				$v_xml_tag_in_db = $arr_xml_tag_in_db[1];
			}
			if (is_null($v_received_record_xml_data)||$v_received_record_xml_data==""){
				$v_received_record_xml_data = '<?xml version="1.0" encoding="UTF-8"?><root><data_list></data_list></root>';
			}
			if ($v_xml_data=="true"){
				$column_rax = new RAX(); 
				$column_rec = new RAX();
				$column_rax->open($v_received_record_xml_data);
				$column_rax->record_delim = 'data_list';
				$column_rax->parse();
				$column_rec = $column_rax->readRecord(); 
				$column_row = $column_rec->getRow();
				$v_value = _restore_XML_bad_char($column_row[$v_xml_tag_in_db]);
				$v_html_string = $v_html_string  . Element_Type($v_type); 
			}else{
				$v_value = $arr_all_record[$row_index][$v_column_name];
				$v_code = $arr_all_record[$row_index]['C_CODE'];  //Them gia tri code de tra lai gia tri cho modal_dilog khi goi danh sach ho so tra cuu
				if ($v_type=="checkbox"){
					$v_value_id = $arr_all_record[$row_index][$v_column_name];
					$v_url = "row_onclick_archives(" . "document.forms(0).hdn_record_id" . "," . $v_value_id . ",'" . $v_code . "','" .$v_fuseaction_onclick."','" . $v_goto_url . "')";
				}
				$v_html_string = $v_html_string  . Element_Type($v_type); 
			}
			$table_struct_rec = $table_struct_rax->readRecord();
		}
		$v_html_string = $v_html_string .'</tr>';
	}
}
if ($v_current_style_name == "odd_row"){
	$v_next_style_name = "round_row";
}else{
	$v_next_style_name = "odd_row";
}
$v_html_string = $v_html_string  . _add_empty_row($v_count,_CONST_NUMBER_OF_ROW_PER_LIST,$v_current_style_name,$v_next_style_name,$v_column);
$v_html_string = $v_html_string  .'</table></div>';
echo $v_html_string;
?>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
	<col width="5%"><col width="95%">
	<tr>
		<td align="right" class="normal_link"><? 
			if ($v_count >0){
				echo PageBreak($v_total_record,$v_page,10,_CONST_NUMBER_OF_ROW_PER_LIST);
			}?>
		</td>
	</tr>
</table>
<table width="100%" align="center" cellpadding="0" cellspacing="0" border="0">
	<tr height="5"><td></td></tr><?php	
	if ((($v_is_granted_update)||(onegate_is_handler_for_recordtype($v_staff_id,$v_recordtype_filter,$_SESSION["recordtype"])))&&($v_total_record>0)&&($_MODAL_DIALOG_MODE!=1)&&($v_recordtype_filter <> '007h')&&(onegate_is_manage_on_post_liciense_for_recordtype($v_recordtype_filter,$_SESSION['recordtype']))){?>
	<tr>
		<td align="center" colspan="10">			
			<input type="button" value="<?php echo $arr_result_label[5]; ?>" name="btn_update_post_license" class="large_button" onClick="btn_update_post_license_onclick(document.forms(0).chk_item_id,document.forms(0).hdn_record_id,'DISPLAY_SINGLE_POST_LICENSE');">
		</td>
	</tr><?php
	}?>
</table>

</form> 
<script>
	set_focus(document.forms(0));
</script>
	
